package com.example.demo.controller.config;

import com.example.demo.controller.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 * @author baisongyuan
 * @className ExceptionHandler
 * @description
 * @date 2022/9/20 22:27
 */
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<Exception> exceptionHandler(Exception e){
        return Result.fail(e);
    }
}
